package org.bigtree.example.constans;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Objects;

/**
 * @author bigTree
 * @since 2025/4/26
 */
@Getter
@RequiredArgsConstructor
public enum GenderEnum {
    FEMALE(0),
    MALE(1);

    @EnumValue      // 写入数据库自动转换为存储该字段值
    @JsonValue      // 返回json序列化时取该字段值
    private final int value;


    public static boolean isValid(Integer value) {
        for (GenderEnum genderEnum : GenderEnum.values()) {
            if (Objects.equals(genderEnum.value, value)) {
                return true;
            }
        }
        return false;
    }
}
